package top.gcl.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import top.gcl.dao.BookMapper;
import top.gcl.entity.Book;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BookSrvlmpl {
    @Resource
    private BookMapper mapper;
    public  int save(Book book){
        return  mapper.save(book);
    }
    public  Book showById(String id){
        return  mapper.showById(id);
    }
    public PageInfo<Book> list(int pageNum,int pageSize){
        Page page= PageHelper.startPage(pageNum,pageSize,true);
        //开始执行查询
        List list =mapper.list();
        PageInfo<Book> pageInfo=new PageInfo<Book>(list,page.getPages());

        return pageInfo;
    }
//    public List<Book> list(){
//        return  mapper.list();
////    }
    public int deleteById(String id)
    {
        return  mapper.deleteById(id);
    }


}
